/*
 *      physics.h
 *      
 *      2009 Víctor Manuel Ochoa <kanito8a@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


#ifndef PHYSICS_H
#define PHYSICS_H

#include <math.h>
#include <stdio.h>
#include <string.h>

#include "vector2.h"
#include "definitions.h"

const float PI=3.14159265;
const float PI_DIV_180=PI/180;
const float _180_DIV_PI=180/PI;
const float BASIC_GRAVITY=0.5f;


class Physics
{
	private:
		
		Vector2 m_position;
		Vector2 m_velocity;
		Vector2 m_scale;
		float 	m_speed;
		float 	m_acceleration;
		float 	m_gravity;
		float 	m_gravityaccel;
		float 	m_angle;
		float 	m_angle_real;
		float 	m_elasticity;
		float 	m_mass;
		float 	m_width;
		float 	m_height;
		bool	m_inground;
		bool 	m_isfloor;
		
	public:
	
		Physics();
		virtual ~Physics();
		bool init();
		bool init(Vector2 _pos,Vector2 _veloc,float _angle,float _speed, float _acc, float _mass);
		void freeMemory();
		void update();
		
		inline const Vector2 *getPosition(){return &m_position;}
		inline const float getX(){return m_position.x;}
		inline const float getY(){return m_position.y;}
		inline const Vector2 *getVelovity(){return &m_velocity;}
		inline const float getSpeed(){return m_speed;}
		inline const float getAcceleration(){return m_acceleration;}
		inline const float getAngle(){return m_angle;}
		inline const float getRealAngle(){return m_angle_real;}
		inline const float getWidth(){return m_width;}
		inline const float getHeight(){return m_height;}
		inline const float getElasticity(){return m_elasticity;}
		inline const bool isFloor(){return m_isfloor;}

		inline void setPosition(Vector2 _pos){m_position=_pos;}
		inline void setX(float _x){m_position.x=_x;}
		inline void setY(float _y){m_position.y=_y;}		
		inline void setVelovity(Vector2 _vel){m_velocity=_vel;}
		inline void setSpeed(float _speed){m_speed=_speed;}
		inline void setAcceleration(float _acc){m_acceleration=_acc;}
		inline void setAngle(float _angle){m_angle=_angle;}
		inline void setWidth(float _width){m_width=_width;}
		inline void setHeight(float _height){m_height=_height;}
		inline void setIsFloor(bool _value){m_isfloor=_value;}
};

#endif /* PHYSICS_H */ 
